import pandas as pd
from pandas import DataFrame
import sys
sys.path.append ('../')
sys.path.append ('../DataMiningPackage')
import data
from data import Data
import DataMiningPackage.Adaboost as AB


class ATrainModel ():

    def __init__(self,col_arr,emotion,mode,categorization,k,group_num) -> None:
        self.TA = None
        self.Model = None
        self.OM = None
        self.data = None
        self.__categorization = categorization
        self.__k = k
        self.__group_num =group_num

        self.OM = Data.ObjMemory()
        path = '../data/' + mode + '/TrainAction.pkl'
        self.TA = self.OM.LoadObj(path)
        for i in range (0,len(col_arr)):
            self.data = pd.concat([self.data,self.TA.Data.iloc[:,col_arr[i]]],axis=1)

        if emotion == 1 or emotion == 2 or emotion == 3:
            self.data = self.data[self.data.iloc[:,2] == emotion]

        self.Model = AB.AdaBoost(self.data,self.__categorization,self.__k,self.__group_num)

    
    def Analysis (self,sample):
        r = self.Model.AdaBoost_Model(sample)
        return r